#include "userobject.h"

#include "gltexture.h"

#include <QList>
#include <QDebug>

UserObject::UserObject()
    :   _programObject(QSharedPointer<QGLShaderProgram>(new QGLShaderProgram()))
{
}

UserObject::~UserObject()
{
}

void UserObject::loadProgram(const QByteArray &vertexShaderSrc, const QByteArray &fragmentShaderSrc)
{
    QGLShader vShader(QGLShader::Vertex);
    if (!vShader.compileSourceCode(vertexShaderSrc))
    {
        qWarning() << vShader.log();
    }
    QGLShader fShader(QGLShader::Fragment);
    if (!fShader.compileSourceCode(fragmentShaderSrc))
    {
        qWarning() << fShader.log();
    }
    _programObject->addShader(&vShader);
    _programObject->addShader(&fShader);
    if (!_programObject->link())
    {
        qWarning() << _programObject->log();
    }
}
